/**
 * 
 */
package br.com.ufrn.aipetro.ga.view.form;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;

import org.hibernate.Session;

import br.com.ufrn.aipetro.ga.domain.entity.device.OperationStatus;
import br.com.ufrn.aipetro.ga.model.persist.hibernate.util.HibernateUtil;

/**
 * @author Lucas
 *
 */
public class OperationStatusController implements Initializable {

	private Session session;
	@FXML private TextField tfdOperationStatusName;
	
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		// TODO Auto-generated method stub
	}
	
	@FXML
	public void saveOperationStatus() {
		session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		
		OperationStatus operationStatus = new OperationStatus(tfdOperationStatusName.getText());
		
		session.save(operationStatus);
		session.getTransaction().commit();
	}

}
